%{
#include "calc.h"
#include "calc.tab.h"
%}

%option yylineno

%%

[a-z]   { /* variables */
          yylval.sIndex = *yytext - 'a';
          return VARIABLE; }

0   { yylval.iValue = 0;
      return INTEGER; }

[1-9][0-9]* { /* integers */
              yylval.iValue = atoi (yytext);
              return INTEGER; }

[-^()<>=+*/;{}]   { /* single-character operators returned as themself */
                   return *yytext; }

">="    { /* other operators returned as tokens */
          return GE; }

"<="   return LE;
"=="   return EQ;
"!="   return NE;
"while"   return WHILE;
"if"   return IF;
"else"   return ELSE;
"print"   return PRINT;

[ \t\n]   { /* ignore whitespace */ ; }

.   yyerror ("Unknown character");

%%

int yywrap (void) {
   return 1;
}
